<?php

class PlayShowingsTest extends BaseTest
{
    public function testInsert()
    {
        $class = new \Orm\PlayShowings\PlayShowingsClass();
		$class['type'] = $this->testNum();
		$class['player_a'] = $this->testNum();
		$class['player_b'] = $this->testNum();
		$class['start_date'] = $this->testStr();
		$class['start_time'] = $this->testStr();
		$class['play_number'] = $this->testNum();
		$class['open_time'] = $this->testStr();
		$class['stop_time'] = $this->testStr();
		$class['score_a'] = $this->testNum();
		$class['score_b'] = $this->testNum();
		$class['status'] = $this->testNum();


        $class->insert();
        $result_class = new \Orm\PlayShowings\PlayShowingsClass();
        $result_class->loadById($class['id']);

		$this->assertEquals($class['type'],$result_class['type']);
		$this->assertEquals($class['player_a'],$result_class['player_a']);
		$this->assertEquals($class['player_b'],$result_class['player_b']);
		$this->assertEquals($class['start_date'],$result_class['start_date']);
		$this->assertEquals($class['start_time'],$result_class['start_time']);
		$this->assertEquals($class['play_number'],$result_class['play_number']);
		$this->assertEquals($class['open_time'],$result_class['open_time']);
		$this->assertEquals($class['stop_time'],$result_class['stop_time']);
		$this->assertEquals($class['score_a'],$result_class['score_a']);
		$this->assertEquals($class['score_b'],$result_class['score_b']);
		$this->assertEquals($class['status'],$result_class['status']);

        return $result_class;
    }

    /**
     * @depends testInsert
     */
    public function testUpdate($class)
    {
		$class['type'] = $this->testNum();
		$class['player_a'] = $this->testNum();
		$class['player_b'] = $this->testNum();
		$class['start_date'] = $this->testStr();
		$class['start_time'] = $this->testStr();
		$class['play_number'] = $this->testNum();
		$class['open_time'] = $this->testStr();
		$class['stop_time'] = $this->testStr();
		$class['score_a'] = $this->testNum();
		$class['score_b'] = $this->testNum();
		$class['status'] = $this->testNum();


        $class->update();
        $result_class = new \Orm\PlayShowings\PlayShowingsClass();
        $result_class->loadById($class['id']);

		$this->assertEquals($class['type'],$result_class['type']);
		$this->assertEquals($class['player_a'],$result_class['player_a']);
		$this->assertEquals($class['player_b'],$result_class['player_b']);
		$this->assertEquals($class['start_date'],$result_class['start_date']);
		$this->assertEquals($class['start_time'],$result_class['start_time']);
		$this->assertEquals($class['play_number'],$result_class['play_number']);
		$this->assertEquals($class['open_time'],$result_class['open_time']);
		$this->assertEquals($class['stop_time'],$result_class['stop_time']);
		$this->assertEquals($class['score_a'],$result_class['score_a']);
		$this->assertEquals($class['score_b'],$result_class['score_b']);
		$this->assertEquals($class['status'],$result_class['status']);

        return $result_class;
    }

    /**
     * @depends testUpdate
     */

    public function testDelete($class)
    {
        $class->delete($class['id']);

        $result_class = new \Orm\PlayShowings\PlayShowingsClass();
        $result_class->loadById($class['id']);
        $this->assertEquals(1, $result_class['is_del']);
        return $result_class;
    }


    /**
     * @depends testInsert
     */
    public static function testClean($class)
    {
        if ($class['id']) {
            $class->realDelete($class['id']);
        }
    }
}